package stack.era.domain.town;

import java.util.ArrayList;
import java.util.HashMap;

import stack.era.constants.TownAttributes;
import stack.era.constants.CrimeAttributes.CrimeType;
import stack.era.constants.ItemAttributes.ItemType;
import stack.era.constants.ItemAttributes.ResourceType;
import stack.era.domain.DomainObject;
import stack.era.domain.item.Item;

public class Town extends DomainObject {

	private static final long serialVersionUID = -9067071765090575837L;
	
	private HashMap<CrimeType, Integer> fineLaws; // Coin
	private HashMap<CrimeType, Integer> sentenceLaws; // Days

	private HashMap<ResourceType, Integer> equilibriumAmount; // Bundles
	private HashMap<ItemType, ArrayList<Item>> stockpile;

	private int level;

	/**
	 * Create a default town object.
	 * 
	 * @param newID
	 * @param newName
	 */
	public Town(String newName) {
		super(newName);

		this.level = 1;
		
		equilibriumAmount = new HashMap<ResourceType, Integer>();
		for(ResourceType rt : ResourceType.values()) {
			equilibriumAmount.put(rt, TownAttributes.DEFAULT_EQUILIBRIUM);
		}
		
		stockpile = new HashMap<ItemType, ArrayList<Item>>();
		for(ItemType it : ItemType.values()) {
			stockpile.put(it, new ArrayList<Item>());
		}
		
		fineLaws = new HashMap<CrimeType, Integer>();
		sentenceLaws = new HashMap<CrimeType, Integer>();

		// Setup default laws
		for (CrimeType ct : CrimeType.values()) {
			switch (ct) {
			case MURDER:
				fineLaws.put(ct, TownAttributes.DEFAULT_MURDER_FINE);
				sentenceLaws.put(ct, TownAttributes.DEFAULT_MURDER_SENTENCE);
				break;
			case MINOR_THEFT:
				fineLaws.put(ct, TownAttributes.DEFAULT_MINOR_THEFT_FINE);
				sentenceLaws.put(ct,
						TownAttributes.DEFAULT_MINOR_THEFT_SENTENCE);
				break;
			case MAJOR_THEFT:
				fineLaws.put(ct, TownAttributes.DEFAULT_MAJOR_THEFT_FINE);
				sentenceLaws.put(ct,
						TownAttributes.DEFAULT_MAJOR_THEFT_SENTENCE);
				break;
			}
		}
	}

	@Override
	public void update() {
		// TODO Auto-generated method stub
		
	}
}
